package com.sjtuy.galtxtreader;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.io.File;

public class BookListItemView extends RelativeLayout {
    TextView bookNameTextView;
    ImageView launchView;
    File bookDir;
    public BookListItemView(final Context context) {
        super(context);
        LayoutInflater.from(context).inflate(R.layout.listitem_mainleft,this);
        bookNameTextView = findViewById(R.id.bookListItemBookName);
        launchView = findViewById(R.id.bookListItemBookLaunch);
        launchView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context,GalActivity.class);
                intent.putExtra("dir",bookDir.getPath());
                intent.putExtra("type","play");
                context.startActivity(intent);
            }
        });
    }
    public void setBookDir(File dir){
        bookDir=dir;
        bookNameTextView.setText(bookDir.getName());
    }
    public String getBookName(){
        return bookNameTextView.getText().toString();
    }

    public File getBookDir() {
        return bookDir;
    }
}
